package com.app.common_app.mapper;

import com.app.common_app.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Optional;

/**
* @author zhangzy
* @description 针对表【user】的数据库操作Mapper
*/
@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 通过phoneNumber查询用户信息
     * @param phone 账号
     * @return 查询结果
     */
    @Select(value = "SELECT * FROM public.user WHERE phone_number = #{phone} AND is_deleted = '0'")
    Optional<User> queryByPhone(String phone);

    /**
     * 通过phoneNumber和密码查询用户信息
     * @param phone 账号
     * @param password 密码
     * @return 查询结果
     */
    @Select(value = "SELECT * FROM public.user WHERE phone_number = #{phone} AND password = #{password} AND is_deleted = '0'")
    Optional<User> queryByPhoneAndPsw(String phone, String password);
}




